<?php 
/** Load header
*/
$this->load->view('header', $template) ;
?>
<link href='http://fonts.googleapis.com/css?family=Allura' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="<?php echo base_url() ?>assets/css/formpage.css">
<!-- <link rel="stylesheet" href="<?php echo base_url() ?>assets/css/user.css"> -->
<!-- ---------------------------------------------------------- -->

<section class="title">
	<div class="wrapper">
		<h2 class='title'>
			Tải tài liệu lên
		</h2>
	</div>
</section>	

<section>
	<div class="wrapper form-visible">
       <!-- 
		<form enctype="multipart/form-data" action="<?php echo base_url() ?>user/get_upload" method="post"> -->
		
		<?php echo $error;?>
		<?php echo form_open_multipart('user/get_upload');?>
			
			<p>
				<input type="file" name="userfile" value="" placeholder="">
			</p>
			<p>
				<label>Tên sách:</label> 
				<input type="text" name="title" value="" placeholder=""> 
			</p>				
			<p>
				<label>Tác giả:</label> 
				<input type="text" name="author" value="" placeholder=""> 
			</p>
			<p>
				<label>Sơ lược:</label>
				<textarea name="description"></textarea>
			</p>
			<p>
				<label>Lĩnh vực:</label>
				<input class="list" list="cat" name="category">
				<datalist id="cat">
					<?php foreach($cat as $c) {
						echo '<option value="'.$c->id_cat.'">'.$c->name_cat.'</option>';
					}  ?>
				</datalist> 
			</p>
			<p>
				<label>Tags:</label>
				<input type="text" name="tags" value="" placeholder=""> 
			</p>
			<p>
				<label>Vị trí liên quan:</label>

				<span class="location">
					<select name="location">
						<option value="00">Không chọn</option>
						<?php foreach($loca as $lo) {
							echo '<option value="'.$lo->id_location.'">'
							.$lo->type_location.' '.$lo->name_location.'</option>';
						}  ?>
					</select>
				</span>

				<!-- <input class="list" list="loca" name="location">
				<datalist id="loca">
					<?php //($loca as $lo) {
						//echo '<option value="'.$lo->id_location.'">'.$lo->name_location.'</option>';
					// }  ?>
				</datalist> -->
			</p>
			<p>
				<input type="submit" name="" value="Upload" placeholder=""> 
				<!-- <input type="button" name="" value="Cancel" placeholder=""> -->
			</p>
			<p>
				<?php if($this->session->flashdata('msg') !== null) 
					echo $this->session->flashdata('msg'); ?>
			</p>
		</form>
	</div>
</section>


<!-- ---------------------------------------------------------- -->
<script>
	$('span.location select').change(function(){
		// alert(this.value);
		$('span.location .child').remove();
		if(this.value != 'null') {
			$.ajax({
				type: "POST",
				url: '/openlibraryonline/book/ajax_child_location/',
				data: ({
					parent: this.value
				}),
				success: function(data) {
					if(data != '')
						$('span.location').append(data);
				}
			});
		}
	});
</script>
<?php
/** Load Footer
*/
$this->load->view('footer') ;
?>